// 统一管理接口
import http from './http'

// 登录+门户/个人中心 判断原密码
export const login = ( data ) => http({
  url: "/login",
  method: 'post',
  data: {
    employee_id: data.username,
    login_password: data.password,
    tenant_id: data.outOrgoutOrg
  },
})

// 管控台左侧菜单
export const getLeftMenu = () => http({
  url: '/systemtoolsindex/menu',
  method: "get"
})

// 管控台首页基础信息
export const getBase = ( data ) => http({
  url: '/systemtoolsindex/base',
  method: 'post',
  headers: {
    "Content-Type": "application/json"
  },
  data
})

// 管控台首页数量信息
export const getCount = ( data ) => http({
  url: '/systemtoolsindex/count',
  method: 'post',
  headers: {
    "Content-Type": "application/json"
  },
  data
})

// 管控台门户管理/应用分类 所有分类
export const getAllCategory = () => http({
  url: '/WorkflowType',
  method: 'get'
})

// 管控台门户管理/应用分类 添加分类
export const addCategory = ( data ) => http({
  url: '/WorkflowType',
  method: 'post',
  data
})

// 管控台门户管理/应用分类 修改分类
export const updateCategory = ( data ) => http({
  url: '/WorkflowType',
  method: 'put',
  data
})

// 管控台门户管理/应用分类 删除分类
export const deleteCategory = ( category_id ) => http({
  url: `/WorkflowType/${category_id}`,
  method: 'delete',
})

// 管控台门户管理/应用分类 拖动修改order
export const changeOrder = ( data ) => http({
  url: '/WorkflowType/changeOrder',
  method: 'post',
  data
})

// 管控台门户管理/菜单管理/信息模块 所有模块
export const getAllInfoBlock = () => http({
  url: '/InfoBlockMenu',
  method: 'get'
})

// 管控台门户管理/菜单管理/信息模块 修改模块
export const updateInfoBlock = ( data ) => http({
  url: '/InfoBlockMenu',
  method: 'put',
  data
})

// 管控台门户管理/新闻管理/全部新闻 分类获取
export const getTargetTypes = ( belong_block_id ) => http({
  url: `/InfoBlockType/${belong_block_id}`,
  method: 'get'
})

// 管控台门户管理/新闻管理/全部新闻 更新分类
export const updateTypes = ( data ) => http({
  url: '/InfoBlockType',
  method: 'put',
  data
})

// 管控台门户管理/新闻管理/全部新闻 list获取
export const getTargetList = ( info_module_id, data ) => http({
  url: `/InfoBlock/${info_module_id}`,
  method: 'post',
  data
})

// 人员搜索组件
export const getPersonInfo = ( data ) => http({
  url: '/searchPerson',
  method: 'post',
  headers: {
    "Content-Type": "application/json"
  },
  data
})

// 上传附件
export const uploadSomething = ( data ) => http({
  url: "/upload",
  method: 'post',
  headers: {
    'Authorization': localStorage.getItem('cookie') || '',
    'Content-Type': 'multipart/form-data'
  },
  data
})

// 管控台系统管理/组织架构 获取根组织
export const getRootNode = () => http({
  url: '/OrganizationalStructure/getRootNode',
  method: "get",
})

// 管控台系统管理/组织架构 获取子组织信息
export const getTargetNodes = ( dept_id ) => http({
  url: `/OrganizationalStructure/${dept_id}`,
  method: 'get'
})


// 管控台系统管理/组织架构 获取组织内的人员
export const getPersonInDept = ( data ) => http({
  url: `/OrganizationalStructure`,
  method: 'post',
  data
})

// 管控台系统管理/组织架构 增加人员
export const addEmployee = ( data ) => http({
  url: "/OrganizationalStructure/addEmployee",
  method: "post",
  data
})

// 管控台系统管理/组织架构 更新人员
export const updateEmployee = ( data ) => http({
  url: "OrganizationalStructure",
  method: "put",
  data
})

// 管控台系统管理/组织架构 停用
export const deactivateEmployee = ( data ) => http({
  url: "OrganizationalStructure/deactivateEmployee",
  method: "put",
  data
})

// 管控台系统管理/组织架构 恢复
export const restoreEmployee = ( data ) => http({
  url: "OrganizationalStructure/restoreEmployee",
  method: "put",
  data
})

// 管控台系统管理/组织架构+门户/个人中心 修改密码
export const changePassword = ( data ) => http({
  url: `OrganizationalStructure/${data.employee_id}`,
  method: "put",
  headers: {
    "Content-Type": "application/json"
  },
  data: data.newPassword,
})

// 管控台门户管理/新闻管理/全部新闻 新建
export const addInfoBlock = ( data ) => http({
  url: '/InfoBlock',
  method: 'post',
  data
})

// 管控台门户管理/新闻管理/全部新闻 终止
export const stopInfoBlock = ( data ) => http({
  url: '/InfoBlock/stop',
  method: 'put',
  data
})

// 管控台门户管理/新闻管理/全部新闻 取消置顶
export const changeIsTop = ( data ) => http({
  url: '/InfoBlock/changeIsTop',
  method: 'put',
  data
})

// 管控台门户管理/新闻管理/全部新闻 删除
export const deleteInfoBlock = ( id ) => http({
  url: `/InfoBlock/${id}`,
  method: 'delete'
})

// 管控台门户管理/新闻管理/全部新闻 发布
export const publishInfoBlock = ( id ) => http({
  url: `/InfoBlock/publishInfoBlock/${id}`,
  method: 'put'
})

// 管控台门户管理/新闻管理/全部新闻 立即生效
export const useRightNow = ( data ) => http({
  url: '/InfoBlock/useRightNow',
  method: 'put',
  data
})

// 管控台门户管理/新闻管理/全部新闻 更改内容
export const changeInfoBlock = ( data ) => http({
  url: '/InfoBlock',
  method: 'put',
  data
})

// 管控台门户管理/菜单管理/导航菜单 获取内容
export const getAllNavMenu = ( data ) => http({
  url: "/MenuManage",
  method: "post",
  data
})

// 管控台门户管理/菜单管理/导航菜单 新建菜单
export const addNavMenu = ( data ) => http({
  url: "/MenuManage/addNavMenu",
  method: "post",
  data
})

// 管控台门户管理/菜单管理/导航菜单 开启状态
export const changeStatus = ( data ) => http({
  url: "/MenuManage/changeStatus",
  method: "put",
  data
})

// 管控台门户管理/菜单管理/导航菜单 编辑菜单
export const editNavMenu = ( data ) => http({
  url: "/MenuManage",
  method: "put",
  data
})

// 管控台门户管理/菜单管理/导航菜单 删除菜单
export const deleteNavMenu = ( menu_id ) => http({
  url: `/MenuManage/${menu_id}`,
  method: 'delete'
})

// 管控台门户管理/菜单管理/导航菜单 搜索菜单
export const searchNavMenu = ( data ) => http({
  url: `/MenuManage/${data.key}`,
  method: "post",
  data
})

// 管控台门户管理/应用排序 列表获取
export const getAllAppInCategory = () => http({
  url: "/ApplySort",
  method: 'get'
}) 

// 管控台门户管理/应用排序 搜索
export const getTargetCategoryApp = ( key ) => http({
  url: '/ApplySort',
  method: 'post',
  headers: {
    "Content-Type": "application/json"
  },
  data: key
})

// 管控台门户管理/应用排序 更改排序
export const changeAppOrder = ( data ) => http({
  url: '/ApplySort',
  method: 'put',
  data
})

// 管控台系统管理/组织架构 添加子部门
export const addSubDept = ( data ) => http({
  url: "/OrganizationalStructure/addSubDept",
  method: "post",
  data
})

// 管控台系统管理/组织架构 改修部门名称
export const changeDeptName = ( data ) => http({
  url: "/OrganizationalStructure/changeDeptName",
  method: "put",
  data
})

// 管控台系统管理/组织架构 删除部门
export const deleteDept = ( dept_id ) => http({
  url: `/OrganizationalStructure/${dept_id}`,
  method: "delete",
})

// 管控台系统管理/组织架构 部门位置移动
export const deptMove = ( data ) => http({
  url: '/OrganizationalStructure/deptMove',
  method: 'put',
  data
})

// 管控台系统管理/组织架构 设置部门负责人
export const setDeptHeader = ( data ) => http({
  url: `/OrganizationalStructure/setDeptHeader/${data.dept_id}`,
  method: 'post',
  data: data.persons
})

// 管控台系统管理/组织架构 搜索部门
export const searchDept = ( key ) => http({
  url: '/OrganizationalStructure/searchDept',
  method: 'post',
  headers: {
    "Content-Type": "application/json"
  },
  data: key
})

// 管控台系统管理/角色管理+权限管理 列表获取
export const getAllRole = ( data ) => http({
  url: '/RoleManagement',
  method: 'post',
  data
})

// 管控台系统管理/角色管理 新增
export const addRole = ( data ) => http({
  url: '/RoleManagement/addRole',
  method: 'post',
  data
})

// 管控台系统管理/角色管理 编辑
export const editRole = ( data ) => http({
  url: '/RoleManagement',
  method: 'put',
  data
})

// 管控台系统管理/角色管理 停用
export const stopRole = ( code ) => http({
  url: `RoleManagement/${code}`,
  method: 'put'
})

// 管控台系统管理/角色管理 启用
export const runRole = ( code ) => http({
  url: `RoleManagement/runRole/${code}`,
  method: 'put'
})

// 管控台系统管理/角色管理 删除
export const deleteRole = ( code ) => http({
  url: `RoleManagement/${code}`,
  method: 'delete'
})

// 管控台系统管理/权限管理 获取权限列表
export const getAuthList = ( data ) => http({
  url: '/FunctionalAuthority',
  method: 'post',
  headers: {
    "Content-Type": "application/json"
  },
  data
}) 

// 管控台系统管理/权限管理 设置权限
export const setAuth = ( data ) => http({
  url: '/FunctionalAuthority/setAuth',
  method: 'post',
  data
})

// 管控台系统管理/安全管理+主题设置/基础信息设置 获取信息
export const getAllSettingsMap = () => http({
  url: '/SecurityManagement',
  method: 'get'
})

// 管控台系统管理/安全管理 修改设置
export const setSetting = ( data ) => http({
  url: '/SecurityManagement',
  method: 'put',
  data
})

// 管控台系统管理/主题设置/报错页面自定义 列表
export const getErrorPageInfo = ( error_type ) => http({
  url: `/BusinessManagement/${error_type}`,
  method: 'get',
})

// 管控台系统管理/主题设置/报错页面自定义 增加
export const addErrorPage = ( data ) => http({
  url: '/BusinessManagement',
  method: 'post',
  data
})

// 管控台系统管理/主题设置/报错页面自定义 修改
export const updateErrorPage = ( data ) => http({
  url: '/BusinessManagement',
  method: 'put',
  data
})

// 管控台系统管理/主题设置/报错页面自定义 删除
export const deleteErrorPage = ( error_type ) => http({
  url: `/BusinessManagement/${error_type}`,
  method: 'delete'
})

// 登录是否需要验证码
export const getIfNeedCode = ( tenant_id ) => http({
  url: `/login/${tenant_id}`,
  method: 'get'
})

// 管控台首页 获取所有menu_code
export const getAllMenuCode = () => http({
  url: '/systemtoolsindex/getAllMenuCode',
  method: 'get'
})

// 管控台流程管理/流程规则 新增
export const addRule = ( data ) => http({
  url: '/processManagePlatform',
  method: 'post',
  data
})

// 管控台流程管理/流程规则 获取列表
export const getAllProcessRule = ( key ) => http({
  url: '/processManagePlatform/getAllProcessRule',
  method: 'post',
  headers: {
    "Content-Type": "application/json"
  },
  data: key
})

// 管控台流程管理/流程规则 重命名
export const changeProcessRule = ( data ) => http({
  url: '/processManagePlatform',
  method: 'put',
  data
})

// 管控台流程管理/流程规则 删除
export const deleteProcessRule = ( code ) => http({
  url: `/processManagePlatform/${code}`,
  method: 'delete'
})

// 管控台流程管理/流程规则/编辑 保存
export const saveProcessRuleContent = ( data ) => http({
  url: `/processManagePlatform/ruleEdit/${data.status}`,
  method: 'post',
  data: data.data
})

// 管控台流程管理/流程规则/编辑 获取列表
export const getProcessRuleContent = ( process_rule_code ) => http({
  url: `/processManagePlatform/ruleEdit/${process_rule_code}`,
  method: 'get'
})

// 管控台流程管理/流程规则/编辑 列表更新
export const updateProcessRuleContent = ( data ) => http({
  url: `/processManagePlatform/ruleEdit/${data.status}`,
  method: 'put',
  data: data.data
})

// 门户/个人中心 上传base64图片
export const uploadBase = (data) => http ({
  url: '/uploadBase',
  method: 'post',
  headers: {
    "Content-Type": "application/json"
  },
  data
})

// 门户/个人中心 重置头像
export const resetAvatar = () => http({
  url: '/personalCenter',
  method: 'put'
})

// 门户/个人中心 获取部门全路径
export const getFullPathDept = ( data ) => http({
  url: '/personalCenter',
  method: 'post',
  headers: {
    "Content-Type": "application/json"
  },
  data
})

// 门户/首页 获取nav
export const getActiveNavMenu = () => http({
  url: 'proportalindex/getActiveNavMenu',
  method: 'get'
})

// 门户/首页 获取轮播图
export const getActiveLunBoPic = () => http({
  url: '/proportalindex/getActiveLunBoPic',
  method: 'get'
})

// 门户/首页 轮播图查看后更新查看人员列表
export const updateViewed = ( id ) => http({
  url: `/proportalindex/updateViewed/${id}`,
  method: 'put'
})

// 门户/首页 获取所有新闻
export const getActiveNews = () => http({
  url: '/proportalindex/getActiveNews',
  method: 'get'
})

// 门户/首页 获取所有通知公告
export const getActiveNotices = () => http({
  url: '/proportalindex/getActiveNotices',
  method: 'get'
})

// 门户/首页 获取所有规则制度
export const getActiveRegulation = () => http({
  url: '/proportalindex/getActiveRegulation',
  method: 'get'
})

// 门户/首页 更新最近使用
export const updateRecentUse = ( app_id ) => http({
  url: `/proportalindex/updateRecentUse/${app_id}`,
  method: 'put'
})

// 门户/首页 收藏
export const updateSelected = ( data ) => http({
  url: '/proportalindex/updateSelected',
  method: 'put',
  data
})

// 门户/应用中心 获取app
export const getAllApps = () => http({
  url: '/appCenter',
  method: 'get'
})

// 门户/应用中心 更新应用
export const updateApp = ( data ) => http({
  url: '/appCenter',
  method: 'put',
  data
})

// 门户/应用中心 获取应用分类
export const getActiveCategory = () => http({
  url: '/appCenter/getActiveCategory',
  method: 'get'
})

// 门户/应用 提交表单
export const submitForm = ( data ) => http({
  url: '/processCenter/submitForm',
  method: 'post',
  data
})

// 门户/流程中心 获取列表
export const getTargetProcessInfo = ( data ) => http({
  url: '/processCenter/getTargetProcessInfo',
  method: 'post',
  data
})

// 门户/应用 获取表单信息
export const getFormData = ( process_id ) => http({
  url: `/processCenter/getFormData/${process_id}`,
  method: 'get'
})

// 门户/流程中心/草稿箱 删除流程
export const deleteProcess = ( process_id ) => http({
  url: `/processCenter/deleteProcess/${process_id}`,
  method: 'delete'
})

// 门户/流程中心 获取单个流程
export const getOneTargetProcess = ( data ) => http({
  url: `/processCenter/getOneTargetProcess/${data.process_id}`,
  method: 'post',
  data
})

// 门户/流程中心 获取节点按钮信息
export const getNodeButtons = ( data ) => http({
  url: '/processCenter/getNodeButtons',
  method: 'post',
  data
})

// 门户/流程中心 审批  管控台/流程管理/流程运维/流程干预
export const setApprovalResult = ( data ) => http({
  url: '/processCenter/setApprovalResult',
  method: 'post',
  data
})

// 应用 获取当前流程节点
export const getSteps = ( process_id ) => http({
  url: `/processCenter/getSteps/${process_id}`,
  method: 'get'
})

// 管控台流程管理/流程运维/流程干预 获取列表
export const getProcessList = ( data ) => http({
  url: 'processManagePlatform/getProcessList',
  method: 'post',
  data
})